<template>
    <a-card :bordered="false">
        <div class="table-operator">
            <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'entityForm','新增')">添加</a-button>
        </div>

        <LTable
            ref="entityList"
            size="small"
            rowKey="keyId"
            :formAttributes="formAttributes"
            :columns="columns"
            axiosUrl="/SysEntityInfoController/page"
            :initQuery="[{field:'systemNo',val:defaultSettings.systemNo}]"
            :initOrder="[{field:'tableName',val:'asc'}]"
            :showPagination="true"
            :showQueryForm="true"
        >
    
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'entityForm',record.entityDesc)">编辑</a>
        </span>
        
    </LTable>

    <entityForm ref="entityForm" @close="refresh('entityList')" @ok="refresh('entityList')"></entityForm> 
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import entityForm from './entityForm'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'

export default {
    name:'entityList',
    components:{
       LTable,entityForm
    },
    mixins:[SysMixin],
    data(){
        return{
            formAttributes:[
                {field:'entityClassName',label:'实体名',component:'input',condition:'like'},
                {field:'tableName',label:'数据库表名',component:'input',condition:'like'},
                {field:'entityDesc',label:'备注',component:'input',condition:'like'},
            ],
            defaultSettings,
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                {
                    title: '实体名',
                    dataIndex: 'entityClassName'
                    
                },
               
                {
                    title: '数据库表名',
                    dataIndex: 'tableName'
                    
                },
                {
                    title: '备注',
                    dataIndex: 'entityDesc'
                },
                {
                    title: '实体类型',
                    dataIndex: 'entityType'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '120px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            
        }
    },
    
}
</script>